import { Context, Next } from 'koa'
import { log } from '../../utils/log'

const logger = async (ctx: Context, next: Next) => {
  const start = new Date().getTime()
  await next()
  const end = new Date().getTime()
  const { method, url } = ctx
  log(`[${method} -- ${(end - start).toFixed(0)}ms]: ${url}`)
}

export default logger
